import { configureStore } from "@reduxjs/toolkit";
import undoable, { excludeAction, StateWithHistory } from "redux-undo";
import { manageReducer, manageType } from "./manage";
import componentsReducer, { ComponentsStateType } from "./componentsReducer";
import { userType } from "./user";
import pageInfoReducer, { PageInfoType } from "./pageInfoReducer";
export type StateType = {
  components: StateWithHistory<ComponentsStateType>;
  manage: manageType[];
  user: userType;
  pageInfo: PageInfoType;
};
export const store = configureStore({
  reducer: {
    // 增加了 undo
    components: undoable(componentsReducer, {
      limit: 20, // 限制 undo 20 步
      filter: excludeAction([
        "components/resetComponents",
        "components/changeSelectedId",
        "components/selectPrevComponent",
        "components/selectNextComponent",
      ]),
    }),
    manage: manageReducer,
    pageInfo: pageInfoReducer,
  },
});
